home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / bin / awf < prev    next >
Text File  |  1995-05-16  |  1KB  |  61 lines

  1. #! /bin/sh
  2. PATH=/bin:/usr/bin:/usr/skunk/bin ; export PATH
  3. # AWFLIB is where the pieces live
  4. AWFLIB=${AWFLIB-/usr/skunk/lib/awf}
  5.  
  6. tmp=/tmp/awp$$                 # tempfile for building pass 2
  7. errs=/tmp/awe$$                # error messages (awk can't send to stderr)
  8.  
  9. case "$1" in
  10. -ms)   mac=ms  ;;
  11. -man)  mac=man ;;
  12. *)     echo "$0: must specify -ms or -man" >&2
  13.        exit 2
  14.        ;;
  15. esac
  16. shift
  17.  
  18. dev="$AWFLIB/dev.$TERM"
  19. if test ! -r $dev
  20. then
  21.        dev="$AWFLIB/dev.dumb"
  22. fi
  23.  
  24. trap "rm -f $tmp $errs ; exit 0" 0 1 2
  25.  
  26. # build the full, macro-set-dependent, pass-2 awk program
  27. (
  28.        sed -n '1,/^#include/p' $AWFLIB/pass2.base
  29.        cat $AWFLIB/pass2.$mac
  30.        sed -n '/^#include/,$p' $AWFLIB/pass2.base
  31. ) >$tmp
  32.  
  33. # do it
  34. (
  35.        echo ".^x $errs"
  36.        echo ".^b"
  37.        echo ".^# 1 <prolog>"
  38.        cat $dev $AWFLIB/common $AWFLIB/mac.$mac
  39.        if test " $*" = " "
  40.        then
  41.                echo ".^# 1 <stdin>"
  42.                cat
  43.        else
  44.                for f
  45.                do
  46.                        echo ".^# 1 $f"
  47.                        cat $f
  48.                done
  49.        fi
  50.        echo ".^e"
  51. ) | awk -f $AWFLIB/pass1 | awk -f $tmp | awk -f $AWFLIB/pass3
  52.  
  53. # error messages, if any
  54. if test -s $errs
  55. then
  56.        cat $errs >&2
  57.        exit 1
  58. else
  59.        exit 0
  60. fi
  61.